#!/bin/bash
echo -e "\t-----------------------------------------------"
echo -e "\t\t 1.lucky man"
echo -e "\t-----------------------------------------------"

#generate a file include all students name
cat >stu_name.txt <<EOF
zhouchang
liwen
zhaowei
zengfenghua
yiguowen
wanda
tangqingyu
liaobingbing
huqianshen
caoyong
chenxingming
hubiwu
xianglingbo
zhangshuai
liqiang
wangtao
sunqiang
cali
EOF

#create an array store all students name

students_name=(`cat stu_name.txt`)

#get a random number
students_c=${#students_name[@]}
lucky_num=$(($RANDOM%$students_c))

#Countdown 3 seconds
for i in {3..1}
do
	echo -e "\t\e[1;34m$i\e[0m" 
        sleep 1
done

#Random student
echo -e "please  \e[31m${students_name[lucky_num]}\e[0m answer teacher feng's question"
unset students_name[lucky_num]
echo ${students_name[@]} >stu_name.txt
echo -e "\n\e[46;31m the rest student have:\e[0m\e[1;32m${students_name[@]}\e[0m"
#num=`cat stu_name.txt |wc -w`
#if (( num==0 ));then
	#read -p "All student has been choose,Do you want to do it again?" Yes
        #cp student_ex.txt  stu_name.txt
#fi


